package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 套餐业务类型(用于个人中心需要展示的项)
 * 创建时间 2019/4/12 8:21 PM
 * 修改时间 2019/4/12 8:21 PM
 * @author chy
 * @since v1.0
 * @version v1.0
 */
@Getter
public enum ValueTypeEnum {
    USER_NUM(1, "userNum", "enum.valueType.name.user_num", "#FFC03D", "icon-yonghuliang"),
    //短信套餐按以前逻辑，不走缓存
    SMS(ValueAddedTypeEnum.SMS.getType(), ValueAddedTypeEnum.SMS.getAlias(), "enum.valueType.name.sms", "#EA7F63", "icon-duanxinshu"),


    CUSTOM_FORM_NUM(ValueAddedTypeEnum.CUSTOM_FORM_NUM.getType(), ValueAddedTypeEnum.CUSTOM_FORM_NUM.getAlias(), "enum.valueType.name.custom_form_num", "#F59C44", "icon-biaodan1"),

    CAPACITY_NUM(ValueAddedTypeEnum.CAPACITY_NUM.getType(), ValueAddedTypeEnum.CAPACITY_NUM.getAlias(), "enum.valueType.name.capacity_num", "#F59C44", "icon-chucunliang"),
    CUSTOM_PROCESS_NUM(ValueAddedTypeEnum.CUSTOM_PROCESS_NUM.getType(), ValueAddedTypeEnum.CUSTOM_PROCESS_NUM.getAlias(), "enum.valueType.name.custom_process_num", "#5CC1A5", "icon-liucheng1"),
    CUSTOM_APPLICATION_NUM(ValueAddedTypeEnum.CUSTOM_APPLICATION_NUM.getType(), ValueAddedTypeEnum.CUSTOM_APPLICATION_NUM.getAlias(), "enum.valueType.name.custom_application_num", "#FFC03D", "icon-applicationManagement"),
    CUSTOM_CHART_NUM(ValueAddedTypeEnum.CUSTOM_CHART_NUM.getType(), ValueAddedTypeEnum.CUSTOM_CHART_NUM.getAlias(), "enum.valueType.name.custom_chart_num", "#51B5FF", "icon-sfa"),
    CALL_CENTER(ValueAddedTypeEnum.CALL_CENTER.getType(), ValueAddedTypeEnum.CALL_CENTER.getAlias(), "enum.valueType.name.call_center", "#5CC1A5", "icon-callScreen"),
    FORM_DATA_NUM(11, "formDataNum", "enum.valueType.name.form_data_num", "#5CC1A5", "icon-shujuliang"),
    CUSTOM_PRINT(12, "customPrint", "enum.valueType.name.custom_print", "#608EE6", "icon-dayin1"),
    IMPORT_AND_EXPORT(13, "importAndExport", "enum.valueType.name.import_and_export", "#608EE6", "icon-daorudaochu"),
    API(14, "api", "enum.valueType.name.api", "#C5D0D8", "icon-API"),
    SFA_NUM(15, "sfaNum", "enum.valueType.name.sfa_num", "#F59C44", "icon-biaodan1"),
    SEARCH_CUSTOMER(16, ValueAddedTypeEnum.SEARCH_CUSTOMER.getAlias(), ValueAddedTypeEnum.SEARCH_CUSTOMER.getName(), "#5cc1a5", "icon-souke2"),
    BUSINESS_RULES(17, "businessRules", "enum.valueType.name.business_rules", "#F59C44", "icon-biaodan1"),
    ESIGN(18, ValueAddedTypeEnum.ESIGN.getAlias(), ValueAddedTypeEnum.ESIGN.getName(), "#FF0000", "icon-eqianbao"),
    DISTRIBUTOR(20, ValueAddedTypeEnum.DISTRIBUTOR.getAlias(), "enum.xbbRefType.name.distributor","#FF0000", "icon-biaodan1"),
    BUSINESS_SEARCH(21, ValueAddedTypeEnum.BUSINESS_SEARCH.getAlias(), ValueAddedTypeEnum.BUSINESS_SEARCH.getName(),"#FF0000", "icon-biaodan1"),
    CONTRACTCOMPARE(22,ValueAddedTypeEnum.CONTRACT_COMPARE.getAlias(),ValueAddedTypeEnum.CONTRACT_COMPARE.getName(),"#20A0FF","web-icon-shenpi2"),
    WORK_ORDER_V2(35, ValueAddedTypeEnum.WORK_ORDER_V2.getAlias(), "enum.valueAddedType.name.workOrderV2","#FF0000", "icon-contract"),

    ;

    /**
     * 套餐类型
     */
    private int type;

    /**
     * 应用模板类型名称
     */
    private String alias;
    /**
     * 应用模板类型名称
     */
    private String name;

    /**
     * 颜色
     */
    private String color;
    /**
     * 图标
     */
    private String icon;

    ValueTypeEnum(int type, String alias, String name, String color, String icon) {
        this.type = type;
        this.alias = alias;
        this.name = name;
        this.color = color;
        this.icon = icon;
    }

    public static ValueTypeEnum getByType(Integer type) {
        for (ValueTypeEnum cache : values()) {

            if (Objects.equals(type, cache.getType())) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
